package com.example.demo.controller;

import com.example.demo.service.UseSQLOfAdmin;
import com.example.demo.service.UseSQLOfOrder;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import java.text.SimpleDateFormat;
import java.util.Date;

@Controller
@RequestMapping("/Admin")
public class AdminController {

    @Autowired
    private UseSQLOfOrder useSQLOfOrder;
    @Autowired
    private UseSQLOfAdmin useSQLOfAdmin;
    @Autowired
    private UserService userService;

    @RequestMapping("/Login")
    public String toLogin() {
        return "admin/login";
    }

    @RequestMapping("/index")
    public String Start() {
        return "admin/starter";
    }

    @RequestMapping("/managers")
    public String toManagers(ModelMap modelMap) {
        modelMap.put("adminList", useSQLOfAdmin.selectAll());
        return "admin/AccountManagers";
    }

    @RequestMapping("/users")
    public String toUser(ModelMap modelMap) {
        modelMap.put("userList", userService.selectAll());
        return "admin/AccountUser";
    }

    @RequestMapping("/order")
    public String toOrder(ModelMap modelMap) {
        modelMap.put("orderList", useSQLOfOrder.selectOfPay());
        return "admin/OrderManagement";
    }

    @RequestMapping("/createAdmin")
    public String toCreateAdmin(ModelMap modelMap) {
        return "admin/createAdmin";
    }
}
